package com.mapper;

import com.pojo.Users;
import org.apache.ibatis.annotations.*;

/**
* @author FoxPrime
* @description 针对表【tb_user】的数据库操作Mapper
* @createDate 2024-11-13 15:43:14
* @Entity com.pojo.Users
*/
public interface UsersMapper {

    int deleteByPrimaryKey(Long id);

    int insert(Users record);

    int insertSelective(Users record);

    Users selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(Users record);

    int updateByPrimaryKey(Users record);

    Users findUserWithOrders(Integer id);

    @Select("select * from tb_user where id = #{id};")
    @Results({@Result(id = true, column = "id", property = "id"),
            @Result(column = "username", property = "username"),
            @Result(column = "address", property = "address"),
            @Result(column = "id", property = "orders",many = @Many(select = "com.mapper.OrdersMapper.selectOrdersByUserId"))
    })
    Users selectUserById(int id);
}
